home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
music
/
eked-m1.zoo
/
src
/
prog_ed.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-19
|
25KB
|
773 lines
/*
* EKED-M1 : Editor for Korg M1 synth; prog_ed.c : program editor
* Copyright (C) 1995 Steven M. Eker (Steven.Eker@brunel.ac.uk)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stddef.h>
#include <osbind.h> /* needed for Vsync() */
#include <string.h>
#include <gemfast.h>
#include <aesbind.h>
#include <vdibind.h>
#include "gm/gem_man.h"
#include "eked-m1.h"
#include "defs.h"
#include "types.h"
#include "externs.h"
#define T_WID 50
#define WIDTH2TIME(w) (((w) == 0) ? 0 : 2 * (w) - 1)
#define TIME2WIDTH(t) (((t) + 1) / 2)
#define HEIGHT2SNUM(h) (((h) == 0) ? 0 : 2 * (h) + (((h) > 0) ? 1 : -1))
#define SNUM2HEIGHT(n) (((n) >= 0) ? (n) / 2 : -((-(n)) / 2))
#define HEIGHT2UNUM(h) (h)
#define UNUM2HEIGHT(n) (n)
#define NO_GRAPH (-2) /* -1 used by objc_find()! */
/*
* Graph control point data structure
*/
typedef struct {
int c_x; /* x offset from GEM graph object */
int c_y; /* y offset from GEM graph object */
#define FIXED (-1)
#define FOLLOW (-2)
int x_ob; /* GEM object for x parameter or FIXED or FOLLOW */
int y_ob; /* GEM object for y parameter or FIXED or FOLLOW */
} CTRL_POINT;
/*
* Graph data structure
*/
typedef struct {
int x_axis_x1; /* x axis */
int x_axis_x2;
int x_axis_y;
int y_axis_x; /* y axis 1 (note on) */
int y_axis_y1;
int y_axis_y2; /* y axis 2 (note off) */
int y_axis2_x;
int y_min; /* minimum y value for control point */
int y_max; /* maximum y value for control point */
int n_points; /* number of control points */
CTRL_POINT point[7]; /* control point array */
int vsync_flag; /* flag to force Vsync() call before redraw */
} GRAPH;
static BITBLK *wave_image[4];
static OBJECT *pitch_mod;
static OBJECT *pitch1;
static OBJECT *pitch2;
static OBJECT *filter_mod;
static OBJECT *filter1;
static OBJECT *filter2;
static OBJECT *misc;
static OBJECT *amp1;
static OBJECT *amp2;
static OBJECT *effect_route;
static OBJECT *effect1;
static OBJECT *effect2;
static BANK *edit_bank; /* bank of program being edited */
static int number; /* number of program being edited */
static int in_use; /* editor in use flag */
static int graph_handle; /* vdi handle for drawing graphs */
static int work_w; /* width of window contents */
static int work_h; /* height of window contents */
static BYTE data[PROGRAM_SIZE]; /* private copy of program */
static BYTE compare[PROGRAM_SIZE]; /* another copy for compare op */
static void prog_setup();
static void display(int x_pos, int y_pos, GRECT *clip, long usr_val);
static int action(int handle, E_TYPE type, void *event,
int x_pos, int y_pos, long usr_val);
static void save_prog(BYTE *p);
static void do_click(int handle, int m_x, int m_y);
static void setup(int x_pos, int y_pos);
static void gpara_setup(OBJECT *tree, int graph_ob,
PARAMETER table[], int size);
static void gpara_edit(int handle, OBJECT *tree, int graph_ob,
PARAMETER table[], int size, int m_x, int m_y);
static void graph_edit(int handle, OBJECT *tree, int ob,
PARAMETER table[], int size, int m_x, int m_y);
static void graph_drag(int handle, OBJECT *tree, int ob,
int x_offset, int y_offset,
CTRL_POINT coord[], int n_move, int link,
VRECT *bound, GRECT *area);
static int graph_draw(PARMBLK *p);
static PARAMETER *find_parameter(PARAMETER table[], int size, int ob);
static void para_setup(OBJECT *tree, PARAMETER table[], int size);
static int misc_buttons(int handle, int ob);
void pe_init()
{
static GRAPH pitch1_graph = {
4, 187, 56, 8, 4, 108, 128, 7, 105, 6,
{
{8, 66, FIXED, P1_ST_LEV},
{8+T_WID, 10, P1_AT_TIME, P1_AT_LEV},
{8+2*T_WID, 56, P1_DC_TIME, FIXED},
{128, 56, FIXED, FIXED},
{128+T_WID, 20, P1_RL_TIME, P1_RL_LEV},
{187, 20, FIXED, FOLLOW}
}
};
static GRAPH pitch2_graph = {
4, 187, 56, 8, 4, 108, 128, 7, 105, 6,
{
{8, 105, FIXED, P2_ST_LEV},
{8+T_WID, 7, P2_AT_TIME, P2_AT_LEV},
{8+2*T_WID, 56, P2_DC_TIME, FIXED},
{128, 56, FIXED, FIXED},
{128+T_WID, 80, P2_RL_TIME, P2_RL_LEV},
{187, 80, FIXED, FOLLOW}
}
};
static GRAPH filter1_graph = {
4, 235, 56, 8, 4, 108, 176, 7, 105, 7,
{
{8, 56, FIXED, FIXED},
{8+T_WID, 90, F1_AT_TIME, F1_AT_LEV},
{8+2*T_WID, 56, F1_DC_TIME, F1_DC_LEV},
{8+3*T_WID, 45, F1_SS_TIME, F1_SS_LEV},
{176, 45, FIXED, FOLLOW},
{176+T_WID, 40, F1_RL_TIME, F1_RL_LEV},
{235, 40, FIXED, FOLLOW}
}
};
static GRAPH filter2_graph = {
4, 235, 56, 8, 4, 108, 176, 7, 105, 7,
{
{8, 56, FIXED, FIXED},
{8+T_WID, 7, F2_AT_TIME, F2_AT_LEV},
{8+2*T_WID, 105, F2_DC_TIME, F2_DC_LEV},
{8+3*T_WID, 20, F2_SS_TIME, F2_SS_LEV},
{176, 20, FIXED, FOLLOW},
{176+T_WID, 40, F2_RL_TIME, F2_RL_LEV},
{235, 40, FIXED, FOLLOW}
}
};
static GRAPH amp1_graph = {
4, 235, 104, 8, 4, 108, 176, 5, 104, 6,
{
{8, 104, FIXED, FIXED},
{8+T_WID, 5, A1_AT_TIME, A1_AT_LEV},
{8+2*T_WID, 104, A1_DC_TIME, A1_DC_LEV},
{8+3*T_WID, 80, A1_SS_TIME, A1_SS_LEV},
{176, 80, FIXED, FOLLOW},
{176+T_WID, 104, A1_RL_TIME, FIXED}
}
};
static GRAPH amp2_graph = {
4, 235, 104, 8, 4, 108, 176, 5, 104, 6,
{
{8, 104, FIXED, FIXED},
{8+T_WID, 5, A2_AT_TIME, A2_AT_LEV},
{8+2*T_WID, 104, A2_DC_TIME, A2_DC_LEV},
{8+3*T_WID, 80, A2_SS_TIME, A2_SS_LEV},
{176, 80, FIXED, FOLLOW},
{176+T_WID, 104, A2_RL_TIME, FIXED}
}
};
static USERBLK pitch1_ub = {(void *) &graph_draw, (long) &pitch1_graph};
static USERBLK pitch2_ub = {(void *) &graph_draw, (long) &pitch2_graph};
static USERBLK filter1_ub = {(void *) &graph_draw, (long) &filter1_graph};
static USERBLK filter2_ub = {(void *) &graph_draw, (long) &filter2_graph};
static USERBLK amp1_ub = {(void *) &graph_draw, (long) &1_graph};
static USERBLK amp2_ub = {(void *) &graph_draw, (long) &2_graph};
graph_handle = gm_opnvwk();
vsf_color(graph_handle, WHITE);
vsm_type(graph_handle, 4);
vsm_color(graph_handle, BLACK);
vsl_udsty(graph_handle, 0xAAAA);
rm_gaddr(R_TREE, PITCH_MOD, &pitch_mod);
rm_gaddr(R_TREE, PITCH1, &pitch1);
rm_gaddr(R_TREE, PITCH2, &pitch2);
rm_gaddr(R_TREE, FILTER_MOD, &filter_mod);
rm_gaddr(R_TREE, FILTER1, &filter1);
rm_gaddr(R_TREE, FILTER2, &filter2);
rm_gaddr(R_TREE, MISC, &misc);
rm_gaddr(R_TREE, AMP1, &1);
rm_gaddr(R_TREE, AMP2, &2);
rm_gaddr(R_TREE, EFFECT_ROUTE, &effect_route);
rm_gaddr(R_TREE, EFFECT1, &effect1);
rm_gaddr(R_TREE, EFFECT2, &effect2);
if(char_h >= 16){
wave_image[0] = (BITBLK *) filter_mod[FM_WAVE].ob_spec;
wave_image[1] = (BITBLK *) pitch_mod[PM_WAVE].ob_spec;
rm_gaddr(R_IMAGEDATA, DOWNSAW, wave_image + 2);
rm_gaddr(R_IMAGEDATA, SQUARE, wave_image + 3);
}
else{
rm_gaddr(R_IMAGEDATA, TRIANGLE_L, wave_image);
rm_gaddr(R_IMAGEDATA, UPSAW_L, wave_image + 1);
rm_gaddr(R_IMAGEDATA, DOWNSAW_L, wave_image + 2);
rm_gaddr(R_IMAGEDATA, SQUARE_L, wave_image + 3);
}
pitch1[P1_GRAPH].ob_spec = (long) &pitch1_ub;
pitch2